class Shard
	#return cleaned array of k/v/u sets by index or range
	def clean(index=nil,endnum=nil)
		@@clean=[]
		if index
			if endnum
				@values[index..endnum].each{|v| @@clean<<[*v]}
			else
				@@clean<<@values[index][*v]
			end
		else
			@values.each{|v| @@clean<<[*v]}
		end

		return @@clean.length>1 ? @@clean : @@clean.flatten
	end

	#prune duplicates
	def prune(*type)
		type.each{|t|
			@@uniqs=[]
			@values.each{|v| @@uniqs.include?(v[t]) ? nil : @@uniqs<<v[t]}
			@values.each{|v| @@uniqs.include?(v[t]) ? @@uniqs.delete(v[t]) : delete(@values.index(v),:pos)}
		}
		update
	end

	#fix incorrect entries
	def corr
		@values.each{|v|
			if not v.is_a?(Struct)
				if v.length!=3||!v.is_a?(Array)
					raise "segment #{v} is not a 3 value array."
				end
				@values<<@Dict2.new(v[0],v[1],v[2])
			end
			if v.is_a?(Array)
				delete(@values.index(v),:pos)
			end
		}
		update
	end
end